%数据参数化
classdef Parametrization
    properties 
        p %数据
    end
    methods
        function obj = Parametrization(a)
            obj.p = a.data;
        end
        function dataPara = USM(obj)
            data = obj.p;
            n = size(data,1);
            dataPara = zeros(1,n);
            for i = 1:n
                dataPara(i) = (i-1)/(n-1);
            end
        end
        function dataPara = CLM(obj)
            data = obj.p;
            n = size(data,1);
            dataPara = zeros(1,n);
            L = GetTwoPointsDis(data, 1);
            for i = 2:(n-1)
                dataPara(i) = sum(L(1:i-1))/sum(L(:));
            end
            dataPara(n) = 1;
        end
        function dataPara = CM(obj)
            data = obj.p;
            n = size(data,1);
            dataPara = zeros(1,n);
            L = GetTwoPointsDis(data, 1/2);
            for i = 2:(n-1)
                dataPara(i) = sum(L(1:i-1))/sum(L(:));
            end
            dataPara(n) = 1;
        end
    end
end 
 function Dis = GetTwoPointsDis(data, p)
            %data控制点 n行2列   q次数(1,弦长 1/2向心)
            n = size(data, 1);
            Dis = zeros(1,n-1);
            for i = 1:n-1
                A = norm(data(i,:) - data(i+1,:));
                Dis(i) = A^(p);
            end
        end 